{% extends "base.html" %}
{% load static debate_tags add_field_css i18n %}

{% block head-title %}<span class="emoji">👯</span> {% trans 'Add Teams' context 'page title' %}
{% blocktrans trimmed with step=wizard.steps.step1 count=wizard.steps.count %}(Step {{ step }} of {{ count }}){% endblocktrans %}{% endblock %}
{% block page-title %}{% trans 'Add Teams' context 'page title' %}{% endblock %}

{% block content %}

<form method="POST">

  {% csrf_token %}
  {{ wizard.management_form }}
  {{ wizard.form.management_form }}

  <div class="mb-3">
    <button type="submit" class="btn btn-outline-primary" name="wizard_goto_step" value="{{ wizard.steps.prev }}"><i data-feather="chevron-left"></i>{% trans "Previous Step" %}</button>
  </div>

  {% if wizard.form.errors %}
    {% include "components/form-errors.html" with errors=wizard.form.non_form_errors %}
  {% endif %}

  {% regroup wizard.form.forms by institution_for_display as forms_by_institution %}

  {% for forms in forms_by_institution %}

    <div class="card mt-3">

      <div class="list-group-item card-title pb-1">
        <h4>
        {% if forms.grouper.name %}
          {% blocktrans trimmed with institution=forms.grouper.name %}
            Teams for {{ institution }}
          {% endblocktrans %}
        {% else %}
          {% trans "Unaffiliated Teams" %}
        {% endif %}
        </h4>
      </div>

      {% for form in forms.list %}
        {% include "components/form-main.html" with double=True %}
      {% endfor %}

    </div>

  {% endfor %}

  <div class="card mt-3">
    {% trans "Save All Teams" as title %}
    {% include "components/form-submit.html" %}
  </div>

</form>

{% endblock content %}
